package cn.edu.cqu.fredyvia.forum.controller;

import cn.edu.cqu.fredyvia.forum.service.ISearchService;
import com.ruoyi.common.core.domain.AjaxResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/search")
public class SearchController {
    @Autowired
    ISearchService iSearchService;

    @PostMapping("/default")
    public AjaxResult search(@RequestParam String key, @RequestParam(defaultValue = "0") String from_param, @RequestParam(defaultValue = "5") String to_param) {
        Integer from = Integer.parseInt(from_param);
        Integer to = Integer.parseInt(to_param);
        return AjaxResult.success(iSearchService.search(key, from, to));
    }
}
